package com.ruoyi.system.service.news.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.ruoyi.system.domain.news.NewsEvaluationAgency;
import com.ruoyi.system.domain.news.query.NewsEvaluationAgencyQuery;
import com.ruoyi.system.domain.news.vo.NewsEvaluationAgencyVo;
import com.ruoyi.system.domain.news.vo.NewsEvaluationAgencyVo;
import com.ruoyi.system.mapper.news.NewsEvaluationAgencyMapper;
import com.ruoyi.system.service.news.NewsEvaluationAgencyService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class NewsEvaluationAgencyServiceImpl extends ServiceImpl<NewsEvaluationAgencyMapper, NewsEvaluationAgency>
        implements NewsEvaluationAgencyService {

    @Override
//    @DataScope(deptAlias = "t",userAlias = "t")
    public List<NewsEvaluationAgencyVo> getNewsEvaluationAgencyList(NewsEvaluationAgencyQuery newsEvaluationAgencyQuery) {
        if (newsEvaluationAgencyQuery.getIfPage()) {
            PageHelper.startPage(newsEvaluationAgencyQuery.getPageNum(), newsEvaluationAgencyQuery.getPageSize());
        }
        List<NewsEvaluationAgencyVo> newsEvaluationAgencyVoList = baseMapper.getNewsEvaluationAgencyList(newsEvaluationAgencyQuery);
        if (!newsEvaluationAgencyVoList.isEmpty() && newsEvaluationAgencyQuery.getId() == null) {
            for (NewsEvaluationAgencyVo newsEvaluationAgencyVo:newsEvaluationAgencyVoList) {
                newsEvaluationAgencyVo.setContent(null);
            }
        }
        return newsEvaluationAgencyVoList;
    }
}
